const { Schema, model } = require('mongoose')
const { format } = require('../utils/index')
const reportSchema = new Schema({
  submitter: {
    type: Schema.ObjectId,
    ref: 'User',
    required: true
  },
  place: {
    type: Schema.ObjectId,
    ref: 'Place',
    required: true
  },
  naturalDate: {
    type: String,
    index: true,
    default: () => format(Date.now(), 'yyyy-MM-dd 00:00:00')
  },
  submitDate: {
    type: Date,
    required: true,
    index: true,
    default: () => Date.now()
  },
  passedItems: {
    type: [String], // item表中的code
    required: true
  },
  unpassedItems: {
    type: [String], // item表中的code
    required: true
  },
  unkownItems: {
    type: [String], // item表中的code
    required: true
  },
  deleted: {
    type: Boolean,
    required: true,
    default: () => false
  },
  note: {
    type: String
  }
})

const reportModel = model('Report', reportSchema)

module.exports = reportModel